# LM75测试构建文件

if meson_build
  drivers_install_dir = meson.project_build_root() / 'opt/bmc/drivers'
  run_command('mkdir', '-p', drivers_install_dir, check: false)
else
  drivers_install_dir = 'opt/bmc/drivers/'
endif

# LM75 I2cStub库源文件
i2c_stub_sources = [
  '../../bus/i2c/drivers/i2c.cpp',
]

# 创建LM75 I2cStub动态库
i2c_stub_lib = shared_library(
  'I2cStub',
  i2c_stub_sources,
  include_directories: [
    include_directories('../../../../drivers/bus/i2c'),
    include_directories('../../../../drivers/internal'),
    include_directories('../../../../tests/drivers/bus/i2c'),
    include_directories('../../../../include'),
    include_directories('../../../../gen'),
  ],
  dependencies: [libmcpp_deps, internal_dep, test_utils_dep],
  install: false,
)

# 创建LM75 I2cStub依赖
i2c_stub_dep = declare_dependency(
  link_with: i2c_stub_lib,
  include_directories: [
    include_directories('../../../../drivers/bus/i2c'),
    include_directories('../../../../drivers/internal'),
    include_directories('../../../../tests/drivers/bus/i2c'),
    include_directories('../../../../include'),
    include_directories('../../../../gen'),
  ],
  dependencies: [libmcpp_deps],
)

lm75_test_sources = [
  '../../../main.cpp',
  'test_lm75_abi.cpp',
] + chip_interface_sources

lm75_test = executable(
  'test_lm75_abi',
  lm75_test_sources,
  include_directories: [
    include_directories('.'),
    include_directories('../../../..'),
    include_directories('../../../../drivers/bus/i2c'),
    include_directories('../../../../drivers/chip/lm75'),
    include_directories('../../../../drivers/chip'),
    include_directories('../../../../drivers/internal'),
    include_directories('../../../../tests/drivers/bus/i2c'),
    include_directories('../../../../include'),
    include_directories('../../../../gen'),
  ],
  dependencies: [
    gtest_dep,
    test_utilities_dep,
    test_utils_dep,
    i2c_stub_dep,
    internal_dep,
    lm75_dep,
    i2c_dep,
  ],
  cpp_args: ['-UHAVE_LIBSOC_ADAPTER'],
  link_with: [],
  install: false,
)

test('test_lm75_abi', lm75_test, timeout: 300, suite: 'lm75')